{% extends "base.html" %}
{% from 'bootstrap5/utils.html' import render_messages %}
{% block title %}🦕 RansomLook 🦖{% endblock %}
{% block content %}
{{ render_messages(container=True, dismissible=True) }}

    <article id="main" class="markdown-section">
        <center>
                <h1>Welcome to 🦕 RansomLook 🦖 !</h1>
        </center>
    <div class="container" style="display: flex;">
        <div style="width: 50%;">
        <p><em>{{ date.title() }}</em></p>

        <p>Currently tracking <code>{{data['nbgroups']}}</code> groups across <code>{{data['nblocations']}}</code> relays & mirrors - <em><code>{{data['online']}}</code> currently online</em>
        <p>Currently tracking <code>{{data['nbforum']}}</code> forums & markets across <code>{{data['nbforumlocations']}}</code> relays & mirrors - <em><code>{{data['forumonline']}}</code> currently online</em>
        <p>Currently tracking <code>{{data['nbtelegram']}}</code> telegram channels.

        <p>There have been <code>{{data['24h']}}</code> posts within the last 24 hours</p>

        <p>There have been <code>{{data['monthlypost']}}</code> posts within the month of {{data['month']}}</p>

        <p>There have been <code>{{data['90d']}}</code> posts within the last 90 days</p>

        <p>There have been <code>{{data['yearlypost']}}</code> posts within the year of {{data['year']}}</p>

        <p>There have been <code>{{data['nbposts']}}</code> posts since the dawn of ransomlook</p>

        <p>There are <code>{{data['nbparsers']}}</code> custom parsers indexing posts</p>
        </div>
        <div style="flex-grow: 1;">
                <center><img src="/static/ransomlook.svg"      width="400" /></center>
        </div>
    </div>

        {% if alert is true %}
           <h1>Alerts within the last 24h</h1>
           {% if 'group' in posts %}
           <h3>Groups and Markets</h3>
           <div class="table-responsive">
            <table id="table" class="table" style="display:table; table-layout:auto; width:100%">
            <thead>
                <tr>
                    <th style="width:15%"> Name </th>
                    <th style="width:15%"> Title </th>
                    <th> Description </th>
                </tr>
            </thead>
            <tbody>
              {% for item in posts['group'] %}
                 <tr>
                  <td> {{ item['group_name'] }} </td><td> {{ item['post_title'] }} </td><td> {{ item['description'] }} </td>
                 </tr>
              {% endfor %}
            </tbody>
            </table>
           </div>
           {% endif %}

           {% if 'telegram' in posts %}
           <h3>Telegram</h3>
           <div class="table-responsive">
            <table id="table" class="table" style="display:table; table-layout:auto; width:100%">
            <thead>
                <tr>
                    <th style="width:15%"> Name </th>
                    <th> Message </th>
                </tr>
            </thead>
            <tbody>
              {% for item in posts['telegram'] %}
                 <tr>
                  <td> {{ item['group_name'] }} </td><td> {{ item['description'] }} </td>
                 </tr>
              {% endfor %}
            </tbody>
            </table>
           </div>
           {% endif %}

           {% if 'twitter' in posts %}
           <h3>Twitter</h3>
           <div class="table-responsive">
            <table id="table" class="table" style="display:table; table-layout:auto; width:100%">
            <thead>
                <tr>
                    <th style="width:15%"> Name </th>
                    <th> Tweet </th>
                </tr>
            </thead>
            <tbody>
              {% for item in posts['twitter'] %}
                 <tr>
                  <td> {{ item['group_name'] }} </td><td> {{ item['description'] }} </td>
                 </tr>
              {% endfor %}
            </tbody>
            </table>
           </div>
           {% endif %}
        {% endif %}
    </article>
{% endblock %}
